package com.david.concurrent.interrupt;

/**
 * @author wade
 * @version 1.0
 * @date 2021/7/20 17:23
 */
public class InterruptDemo {
    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(() -> {
            for (; ; ) {
            }
        });
        thread.start();
        //设置中断标志位
        thread.interrupt();
        //获取中断标志
        System.out.println("isInterrupted:"+thread.isInterrupted());
        //获取中断标志并重置
        System.out.println("isInterrupted:"+thread.interrupted());
        //获取中断标志并重置
        System.out.println("isInterrupted:"+Thread.interrupted());
        ////获取中断标志
        System.out.println("isInterrupted:"+thread.isInterrupted());
        thread.join();
        System.out.println("main is over");
    }
}
